import {getUrlParam,filterData2} from '@/static/js/filter.js';
import member  from '@/components/selectMember/selectMember.vue';
const TCMdata = require('@/pages/quickly/tcm/createTCM.json')
import html2canvas from 'html2canvas'
export default {
	components:{member},
	data () {
		return {
			currentIndex: '',
			dialog: false,
			searchContent: '',
			memberName: '', //会员名称
			userName: '',
			current: '',
			collapseData :TCMdata,
			list: [],
			userId: '',
			defaultArr:[{typeName:'平和质'},{typeName:'气虚质'},{typeName:'阳虚质'},{typeName:'阴虚质'},{typeName:'痰湿质'},{typeName:'湿热质'},{typeName:'血瘀质'},{typeName:'气郁质'},{typeName:'特禀质'}],
			AppPhysiqueScoreEntity:'',
			sex:'',
			physicalArr:[{typeName:'平和质',checked:false},{typeName:'气虚质',checked:false},{typeName:'阳虚质',checked:false},{typeName:'阴虚质',checked:false},{typeName:'痰湿质',checked:false},{typeName:'湿热质',checked:false},{typeName:'血瘀质',checked:false},{typeName:'气郁质',checked:false},{typeName:'特禀质',checked:false},{typeName:'偏颇体质',checked:false}],
			choose:'',
			criterionArr:['','','',''],
			show1:false,
			show2:false,
			show3:false,
			createdDate: '',
			statusTCM: '',
			editId: '',
			healthName: '',
			modifiedDate: '',
			modifyScores: '',//健康管理师是否修正分数状态
			firstFocus:false,
			secondFocus:false,
			threeFocus:false,
			aa: false,
			mark: '',
			titleContent: '中医体质辨识问卷详情',
			accordion: true,
			isAmended: '',
			signDate: '', //确认签发时间
			showModal: false,
			showModal1: false,
			showContent: '',
			showContent1: '',
			sex: '', //性别
			base64:'',
			base64Two:''
		}
	},
	onShow(){
		localStorage.removeItem('questionData')
	},
	mounted() {		
		const _this = this;
		_this.collapseData = TCMdata.map((a)=>{
			a.data.map((b)=>{
				b.options.map((c)=>{
					c.checked = false
					if(c.option){
						c.option.map((d)=>{
							d.checked = false
						})
					}
				})
			})
			return a
		})
		_this.statusTCM = getUrlParam('status') || null;
		if(getUrlParam('id')){
			_this.editId = getUrlParam('id');
			_this.type = 'edit';
			_this.$api.appchinesemedicineexaminationInfo(getUrlParam('id')).then((res)=>{
				_this.userId = res.data.result && res.data.result.userId;
				_this.memberName = res.data.result && res.data.result.userName;
				_this.userName = res.data.result && res.data.result.userName;
				_this.healthName = res.data.result && res.data.result.healthName;
				_this.createdDate = res.data.result && res.data.result.createdDate;
				_this.modifiedDate = res.data.result &&res.data.result.modifiedDate;
				_this.lookUserParam();
				// 编辑数据回显
				if(res.data.result.constitution){
					const constitution = JSON.parse(res.data.result.constitution).filter((a)=>{
						return a
					})
					if(constitution.length == 4){
						_this.show1 = true
						_this.show2 = true
						_this.show3 = true
						_this.criterionArr = JSON.parse(res.data.result.constitution)
					}else{
						_this.show3 = true
						_this.criterionArr = JSON.parse(res.data.result.constitution)
					}
				}
				res.data.result.appFourDiagnosticEntities.map((a)=>{
					_this.collapseData.map((b)=>{
						b.data.map((c)=>{
							if(c.type == a.type){
								c.options.map((d)=>{
									if(d.title == a.name){
										d.checked = true
									}
									if(d.option){
										d.option.map((e)=>{
											if(e.title == a.name){
												e.checked = true
											}
										})
									}
								})
							}
						})
					})
				})
			})
		}else if(localStorage.memberInformationTcm){
			const memberInformationTcmArr = JSON.parse(localStorage.memberInformationTcm);
			_this.userId = memberInformationTcmArr.userId;
			_this.memberName = memberInformationTcmArr.userName;
			_this.userName = memberInformationTcmArr.userName;
			_this.healthName = memberInformationTcmArr.healthName;
			_this.createdDate = memberInformationTcmArr.createdDate;
			_this.modifiedDate = memberInformationTcmArr.modifiedDate;
			_this.edirId = memberInformationTcmArr.id;
			_this.lookUserParam();
			if(memberInformationTcmArr.constitution){
				const constitution = JSON.parse(memberInformationTcmArr.constitution).filter((a)=>{
					return a
				})
				if(constitution.length == 4){
					_this.show1 = true
					_this.show2 = true
					_this.show3 = true
					_this.criterionArr = JSON.parse(memberInformationTcmArr.constitution)
				}else{
					_this.show3 = true
					_this.criterionArr = JSON.parse(memberInformationTcmArr.constitution)
				}
			}
			memberInformationTcmArr.appFourDiagnosticEntities.map((a)=>{
				_this.collapseData.map((b)=>{
					b.data.map((c)=>{
						if(c.type == a.type){
							c.options.map((d)=>{
								if(d.title == a.name){
									d.checked = true
								}
								if(d.option){
									d.option.map((e)=>{
										if(e.title == a.name){
											// console.log(e)
											e.checked = true
										}
									})
								}
							})
						}
					})
				})
			})
		} 
		if(localStorage.getItem('calculatePoints')) {
			this.defaultArr = JSON.parse(localStorage.getItem('calculatePoints')) && JSON.parse(localStorage.getItem('calculatePoints')).appPhysiqueScoreEntitiesvo.map((a)=>{
				return a
			})
			this.createdDate = JSON.parse(localStorage.getItem('calculatePoints')).createdDate
		}
	},
	methods:{
		filterData2,
		toImg(dom) {
			var dom = dom // 获取dom元素
			return new Promise((resolve,reject)=>{
				// 使页面滑到顶部，避免顶部出现白边
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				})
				html2canvas(dom, {
					width: dom.clientWidth, //dom 原始宽度
					height: dom.clientHeight,
					scrollY: 0, // html2canvas默认绘制视图内的页面，需要把scrollY，scrollX设置为0
					scrollX: 0,
					useCORS: true, //支持跨域，但好像没什么用
				}).then((canvas) => {
					// 将生产的canvas转为base64图片
					if(dom.attributes[1].nodeValue == 'poster' || dom.attributes[1].nodeValue == 'poster3'){
						this.base64 = canvas.toDataURL('image/png')
					}else{
						this.base64Two = canvas.toDataURL('image/png')
					}
					resolve(true)
				});
			})
		},
		// 生成雷达图
		creatRadar(){
			return new Promise((resolve, reject)=>{
				const resultData = this.isAmended == 2 ? this.defaultArr : localStorage.calculatePoints ? JSON.parse(localStorage.calculatePoints).appPhysiqueScoreEntities : this.defaultArr
				const data = resultData.map((a)=>{
					return this.isAmended == 2? a.healthScore : a.score
				})
				const indicator = resultData.map((a)=>{return {name:a.typeName,max:100}})
				var myChart = this.$echarts.init(document.getElementById('main'));
				var option = {
					radar: {
						name: {textStyle: {color: '#d46d1e',backgroundColor: '#fff3e8',borderRadius: 3,padding: [3, 5]}},
						indicator: indicator
					},
					series: [{
						type: 'radar',
						itemStyle:{color:'#d46d1e'},
						lineStyle:{color:'#d46d1e',},
						areaStyle:{color:'#ffdbc0',},
						data: [{value: data}]
					}]
				};
				myChart.setOption(option);
				resolve(true)
			})
		},
		// 确认分数
		scoreSure() {
			const id = this.editId ? this.editId : JSON.parse(localStorage.getItem('calculatePoints')) ? JSON.parse(localStorage.getItem('calculatePoints')).id : null
			if(id) {
				this.showModal = true;
				this.showContent = '请确认转化分无误，再将中医评估发送';
			}else {
				this.showModal1 = true;
				this.showContent1 = '该用户还没有问卷，请先添加问卷';
			}
		},
		Modalconfirm() {
			const appConstitutionEntityVo = {
				id:this.editId ? this.editId : JSON.parse(localStorage.getItem('calculatePoints')) ? JSON.parse(localStorage.getItem('calculatePoints')).id : null,
				userId:this.userId,
				healthId:JSON.parse(localStorage.userInfo).id,
			}
			
			
			this.$api.AppConstitutionQuestionnaireScoreSure(appConstitutionEntityVo).then((res) => {
				if(res.data.returnCode == '200') {
					localStorage.removeItem('calculatePoints');
					uni.showToast({
						title: '分数确认成功',
						icon: 'none'
					})
					this.signDate = res.data.result.signDate,
					this.healthName = res.data.result.healthName
				}
			})
		},
		collapseChange(e){	
			uni.pageScrollTo({
				scrollTop: 0,
				duration: 100
			});
		},
		hidedialog(){
			this.dialog = false
		},
		chooseUser(e){
			this.userId = e.userId;
			this.userName = e.userName;
			this.phone = e.phone;
			this.sex = e.sex;
			this.lookUserParam();
			this.statusQuestion();
		},
		clear(){
			if(this.statusTCM == 1 || this.statusTCM == null) {
				this.criterionArr = ['','','','']
				this.show1 = ''
				this.show2 = ''
				this.show3 = ''
				this.choose = ''
				this.physicalArr.map((a)=>{ a.checked = false; return a})
			}
		},
		physicalChoose(b,bi,item){
			const _this = this;
			if(!_this.choose){
				return;
			}
			if(_this.choose == 4){
				var str = ''
				_this.criterionArr.map(a=>{
					str += str+a+','
				})
				if(str.indexOf(b) > -1){
					return;
				}
				_this.$set(_this.criterionArr,[3],!_this.criterionArr[3]?b:_this.criterionArr[3]+','+b);
				item.checked = true
				return;
			}
			if(_this.criterionArr[0] && _this.criterionArr[0] != '偏颇体质'){
				// const data = _this.physicalArr
				// _this.physicalArr = data.map((a)=>{if(a.typeName == _this.criterionArr[0]){ a.checked = true }else{a.checked = false;} return a})
				var str = ''
				_this.criterionArr.map(a=>{
					str += str+a+','
				})
				if(str.indexOf(b) > -1){		
					return;
				}
				_this.show1 = false;
				_this.show2 = false;
				_this.$set(_this.criterionArr,[3],!_this.criterionArr[3]?b:_this.criterionArr[3]+','+b)
				item.checked = true
				return;
			}else if(_this.criterionArr[0] && _this.criterionArr[0] == '偏颇体质'){
				if(!_this.criterionArr[1]){
					_this.firstFocus = false
					_this.secondFocus = true
					_this.$set(_this.criterionArr,[1],b)
					item.checked = true;
					return;
				}else{
					var str = ''
					_this.criterionArr.map(a=>{
						str += str+a+','
					})
					if(str.indexOf(b) > -1){
						return;
					}
					_this.$set(_this.criterionArr,[2],!_this.criterionArr[2]?b:_this.criterionArr[2]+','+b);
					item.checked = true
					return;
				}
			}
			if(_this.choose == 1){
				if(bi == 9){
					_this.show1 = true
					_this.show2 = true
					_this.show3 = true
					_this.aa = false
					_this.firstFocus = true
				}else{				
					_this.show3 = true
					_this.aa = false
					_this.threeFocus = true
					// _this.$set(_this,'firstFocus',true)
				}
				if(_this.criterionArr[0] && _this.criterionArr[0] == '偏颇体质'){
					return;
				}
				_this.$set(_this.criterionArr,[0],b)
				item.checked = true
			}
		},
		chooseNo(e){
			this.aa = false;
			this.firstFocus = false;
			this.secondFocus = false;
			this.threeFocus = false;
			if(e == 1){
				this.aa = true
			}else if(e == 2){
				this.firstFocus = true
			}else if(e == 3){
				this.secondFocus = true
			}else{
				this.threeFocus = true
			}
			this.choose = e;
		},
		// 舌型选择
		check2(index,bindex,aindex,bitem,indexTow){
			this.$set(this.collapseData[index].data[aindex].options[indexTow].option[bindex],'checked',!bitem.checked)
		},
		// 选择事件
		check(itemTow,aindex,index,indexTow){
			this.$set(this.collapseData[index].data[aindex].options[indexTow],'checked',!itemTow.checked)
		},
		// 截取时间
		shijiantime(times){
			var timearr = times.replace(" ", ":").replace(/\:/g, "-").split("-");
			var timestr = ""+timearr[0]+"-" + timearr[1] + "-" + timearr[2]
			return timestr
		},
		// 查看是否有未签发的问卷
		statusQuestion() {
			this.$api.findByStatusTcm(this.userId).then((res) => {
				if(res.data.returnCode == '506') {
					uni.showToast({
						title: res.data.message,
						icon: 'none'
					})
					setTimeout(() => {
						uni.navigateTo({
							url:'/pages/quickly/tcm/list'
						})
					},1000)
				}
			})
		},
		// 查看用户转化分
		lookUserParam() {
			this.defaultArr = [{typeName:'平和质'},{typeName:'气虚质'},{typeName:'阳虚质'},{typeName:'阴虚质'},{typeName:'痰湿质'},{typeName:'湿热质'},{typeName:'血瘀质'},{typeName:'气郁质'},{typeName:'特禀质'}]
			this.$api.newScore({userId:this.userId}).then((res) => {
				if(!res.data.result){
					uni.showToast({
						title:'该用户不存在问卷！',
						icon:'none'
					})
					this.createdDate = '';
					this.signDate = '';
					this.isAmended = ''; //是否修正状态  1未修正  2修正
					return

				}
				if(res.data.result && res.data.result.appConstitutionEntity.type == 2){
					if(!getUrlParam('id')){
						uni.showToast({
							title:'该问卷不是最新问卷，请重新添加！',
							icon:'none'
						})
						this.createdDate = '';
						this.signDate = '';
						this.isAmended = ''; //是否修正状态  1未修正  2修正
						this.type = res.data.result && res.data.result.type;
						return
					}
				}

				this.appConstitutionEntityType = res.data.result && res.data.result.appConstitutionEntity.type
				this.editId = res.data.result && res.data.result.appConstitutionEntity.id
				this.AppPhysiqueScoreEntity = res.data.result && res.data.result.appConstitutionEntity.appPhysiqueScoreEntities;
				this.titleContent = this.AppPhysiqueScoreEntity ? '中医体质辨识问卷详情' : '添加新的问卷';
				this.defaultArr = res.data.result && res.data.result.appConstitutionEntity.appPhysiqueScoreEntitiesvo.map((a)=>{
					return a
				})
				this.appPhysiqueScoreEntitiesvoHealthSort = res.data.result && res.data.result.appConstitutionEntity.appPhysiqueScoreEntitiesvoHealthSort.map((a)=>{
					return a
				})
				this.userName = res.data.result && res.data.result.appConstitutionEntity.userName;
				this.healthName = res.data.result && res.data.result.appConstitutionEntity.healthName;
				this.signDate = res.data.result && res.data.result.appConstitutionEntity.signDate;
				this.createdDate = res.data.result && res.data.result.appConstitutionEntity.createdDate;
				this.modifiedDate = res.data.result && res.data.result.appConstitutionEntity.modifiedDate;
				this.modifyScores = res.data.result && res.data.result.appConstitutionEntity.status;
				this.mark = res.data.result && res.data.result.appConstitutionEntity.mark;
				this.isAmended = res.data.result && res.data.result.appConstitutionEntity.isAmended; //是否修正状态  1未修正  2修正
				// 
			})
		},
		// 过滤选中的数据
		filterCheckTrue(data){
			const _this = this;
			var _filter = data.filter((a)=>{
				if(a.data){
					this.filterCheckTrue(a.data)
				}else if(a.options){
					this.filterCheckTrue(a.options)
				}else if(a.option){
					this.filterCheckTrue(a.option)
				}else{
					return a.checked
				}
			})
			_this._result = _this._result.concat(_filter)
			return _this._result
		},
		seveAdd(e){
			const _this = this;
			uni.showLoading({title:'加载中...'})
			this.toImg(this.isAmended == 2 ? document.querySelector('#poster3') : document.querySelector('#poster')).then(()=>{
				this.creatRadar().then(()=>{
					setTimeout(()=>{
						this.toImg(document.querySelector('#poster2')).then(()=>{
							if(!_this.userId){
								uni.showToast({
									title:'请先选择会员！',
									icon:'none'
								})
								return;
							}
							let pdfType = ''
							if(_this.criterionArr[0] == '偏颇体质') {
								if(_this.criterionArr[1]=='平和质' ) {
									pdfType = 'Peaceful'
								}
								if(_this.criterionArr[1]=='血瘀质') {
									pdfType = 'Sasisofblood'
								}
								if(_this.criterionArr[1]=='气虚质') {
									pdfType = 'Deficiency'
								}
								if(_this.criterionArr[1]=='阳虚质') {
									pdfType = 'Yangdeficiency'
								}
								if(_this.criterionArr[1]=='阴虚质') {
									pdfType = 'Yindeficiency'
								}
								if(_this.criterionArr[1]=='痰湿质') {
									pdfType = 'Phlegmdampness'
								}
								if(_this.criterionArr[1]=='湿热质') {
									pdfType = 'Dampheat'
								}
								if(_this.criterionArr[1]=='气郁质') {
									pdfType = 'Depression'
								}
								if(_this.criterionArr[1]=='特禀质') {
									pdfType = 'Special'
								}
							} else {
								if(_this.criterionArr[0]=='平和质' ) {
									pdfType = 'Peaceful'
								}
								if(_this.criterionArr[0]=='血瘀质') {
									pdfType = 'Sasisofblood'
								}
								if(_this.criterionArr[0]=='气虚质') {
									pdfType = 'Deficiency'
								}
								if(_this.criterionArr[0]=='阳虚质') {
									pdfType = 'Yangdeficiency'
								}
								if(_this.criterionArr[0]=='阴虚质') {
									pdfType = 'Yindeficiency'
								}
								if(_this.criterionArr[0]=='痰湿质') {
									pdfType = 'Phlegmdampness'
								}
								if(_this.criterionArr[0]=='湿热质') {
									pdfType = 'Dampheat'
								}
								if(_this.criterionArr[0]=='气郁质') {
									pdfType = 'Depression'
								}
								if(_this.criterionArr[0]=='特禀质') {
									pdfType = 'Special'
								}
							}
							if(this.appConstitutionEntityType == 2){
								uni.showToast({
									title:'该问卷不是最新问卷，请重新添加！',
									icon:'none'
								})
								return;
							}
							if(!this.signDate) {
								uni.showToast({
									title:'该问卷还未确认分数，请先确认分数！',
									icon:'none'
								})
								return;
							}
							_this._result = []
							this.collapseData.map((a,ai)=>{
								a.data && a.data.map((b,bi)=>{
									b.name = b.title
									b.parentId = ai
									b.options && b.options.map((c)=>{
										c.name = b.title
										c.parentId = ai
										c.option && c.option.map((d)=>{
											d.name = b.title
											d.parentId = ai
										})
									})
								})
							})
							const data = this.filterCheckTrue(this.collapseData)
							const appFourDiagnosticEntities = data.map((a)=>{
								return {
									name:a.title,
									parame:a.userOption,
									type:a.type,
									parentName:a.name,
									parentId: a.parentId
								}
							})
							_this.editId = getUrlParam('id');
							if(e == 2){
								uni.hideLoading()
								if(!_this.criterionArr[0]){
									uni.showToast({title:'请选择为什么体质',icon:"none"})
									return;
								}else{
									if(_this.criterionArr[0] == '偏颇体质'){
										if(!_this.criterionArr[1]){
											uni.showToast({title:'请选择以什么体质为主',icon:"none"})
											return;
										}
									}
								}
								uni.showModal({
									title: '提示',
									content: '请确认数据准确，发送后不可修改。',
									success: function(res) {
										if (res.confirm) {
											uni.showLoading({title:'加载中...'})
											_this.$api.appchinesemedicineexaminationSave({
												constitution:JSON.stringify(_this.criterionArr),
												appFourDiagnosticEntities:appFourDiagnosticEntities,
												healthId:JSON.parse(localStorage.userInfo).id,
												userId:_this.userId,status:
												e,id:Number(_this.editId) || null,
											},pdfType).then((ares)=>{
												if(ares.data.returnCode == '200'){
													var arr = _this.base64Two.split(',')
													var mime = arr[0].match(/:(.*?);/)[1]
													var bstr = atob(arr[1]) 
													var nn = bstr.length 
													var u8arr = new Uint8Array(nn);
													while(nn--){
														u8arr[nn] = bstr.charCodeAt(nn);
													}
													var obj = new Blob([u8arr], {type:mime});
													_this.$api.uploadPdf({file:obj,id:ares.data.result.id,type:pdfType}).then((cres)=>{
														if(cres.returnCode == 200){
															uni.hideLoading()
															localStorage.removeItem('memberInformationTcm')
															uni.navigateTo({
																url:'/pages/quickly/tcm/list'
															})
														}
													})
												}else if(ares.data.returnCode == '506') {
													uni.showToast({
														title: ares.data.message,
														icon: 'none'
													})
												}
											})
										} else if (res.cancel) {
											// console.log('用户点击取消');
										}
									}
								});
							}else if(e == 2  &&  _this.editId){
								uni.hideLoading()
								if(!_this.criterionArr[0]){
									uni.showToast({title:'请选择为什么体质',icon:"none"})
									return;
								}else{
									if(_this.criterionArr[0] == '偏颇体质'){
										if(!_this.criterionArr[1]){
											uni.showToast({title:'请选择以什么体质为主',icon:"none"})
											return;
										}
									}
								}
								uni.showModal({
									title: '提示',
									content: '请确认数据准确，发送后不可修改。',
									success: function(res) {
										if (res.confirm) {
											_this.$api.appchinesemedicineexaminationSave({
												constitution:JSON.stringify(_this.criterionArr),
												appFourDiagnosticEntities:appFourDiagnosticEntities,
												healthId:JSON.parse(localStorage.userInfo).id,
												userId:_this.userId,
												status:e,id:Number(_this.editId)|| null,
											},pdfType).then((ares)=>{
												if(ares.data.returnCode == '200'){
													var arr = _this.base64Two.split(',')
													var mime = arr[0].match(/:(.*?);/)[1]
													var bstr = atob(arr[1]) 
													var nn = bstr.length 
													var u8arr = new Uint8Array(nn);
													while(nn--){
														u8arr[nn] = bstr.charCodeAt(nn);
													}
													var obj = new Blob([u8arr], {type:mime});
													_this.$api.uploadPdf({file:obj,id:ares.data.result.id,type:pdfType}).then((cres)=>{
														if(cres.returnCode == 200){
															uni.hideLoading()
															localStorage.removeItem('memberInformationTcm')
															uni.navigateTo({
																url:'/pages/quickly/tcm/list'
															})
														}
													})
												}else if(ares.data.returnCode == '506') {
													uni.showToast({
														title: ares.data.message,
														icon: 'none'
													})
												}
											})
										} else if (res.cancel) {
											// console.log('用户点击取消');
										}
									}
								});
							}else{
								const id = getUrlParam('id') ? getUrlParam('id') : null;
								_this.$api.appchinesemedicineexaminationSave({
									constitution:JSON.stringify(_this.criterionArr),
									appFourDiagnosticEntities:appFourDiagnosticEntities,
									healthId:JSON.parse(localStorage.userInfo).id,
									userId:Number(_this.userId),
									status:e,id:Number(id) ? Number(id) : null
								},'').then((res)=>{
									if(res.data.returnCode == '200') {
										uni.hideLoading()
										localStorage.removeItem('memberInformationTcm');
										uni.showToast({
											title: '保存成功',
											icon: 'none'
										})
										setTimeout(() => {
											uni.navigateTo({
												url:'/pages/quickly/tcm/list'
											})
										},1000)
									}else if(res.data.returnCode == '506') {
										uni.showToast({
											title: res.data.message,
											icon: 'none'
										})
									}
								})
							}
						})
					},1000)
				})
			})
		},
		// 修正转化分  看用户问卷
		checkCorrect() {
			const _this = this;
			if(!_this.userId) {
				uni.showToast({
					title: '请先选择会员',
					icon: 'none'
				})
				return
			}
			_this._result = []
			const data = _this.filterCheckTrue(_this.collapseData)
			const appFourDiagnosticEntities = data.map((a)=>{
				return {
					name:a.title,
					parame:a.userOption,
					type:a.type					
				}
			})
			const memberInformationTcm = {constitution:JSON.stringify(_this.criterionArr),appFourDiagnosticEntities:appFourDiagnosticEntities,healthId:JSON.parse(localStorage.userInfo).id,userId:_this.userId,userName:_this.userName,id:_this.editId ? Number(_this.editId) : null}
			localStorage.setItem('memberInformationTcm',JSON.stringify(memberInformationTcm))
			const sex = this.sex ? this.sex : getUrlParam('sex');
			if(this.editId && this.mark != 2 && !this.signDate) {
				uni.navigateTo({
					url:'/pages/quickly/tcm/questionnaireDetailTCM?id='+this.userId+'&editId='+this.editId+'&sex='+sex+'&isAmended='+this.isAmended
				})
			} else if(this.editId && this.mark != 2 && this.signDate) {
				uni.navigateTo({
					url:'/pages/quickly/tcm/questionnaireDetailTCM?id='+this.userId+'&editId='+this.editId+'&sex='+sex+'&isAmended='+this.isAmended+'&signData='+this.signDate
				})
			} else if(this.mark == 2  || this.editId) {
				if(localStorage.calculatePoints && JSON.parse(localStorage.calculatePoints).id) {
					const id = localStorage.calculatePoints && JSON.parse(localStorage.calculatePoints).id;
					uni.navigateTo({
						url: '/pages/quickly/tcm/questionnaireDetailTCM2?userId='+this.userId+'&sex='+sex+'&isAmended='+this.isAmended+'&mark='+this.mark+'&editId='+id 
					})
				} else {
					uni.navigateTo({
						url: '/pages/quickly/tcm/questionnaireDetailTCM2?userId='+this.userId+'&sex='+sex+'&isAmended='+this.isAmended+'&mark='+this.mark+'&editId='+this.editId 
					})
				}
				
			} 
			
		},
		tcmDetails() {
			const _this = this;
			if(!_this.userId) {
				uni.showToast({
					title: '请先选择会员',
					icon: 'none'
				})
				return
			}
			
			if(localStorage.calculatePoints && JSON.parse(localStorage.calculatePoints).appPhysiqueScoreEntitiesvo.length == 9) {
				return
			} else if(_this.createdDate) {
				return
			}
			
			const sex = _this.sex ? _this.sex : getUrlParam('sex');
			_this._result = []
			const data = _this.filterCheckTrue(_this.collapseData)
			const appFourDiagnosticEntities = data.map((a)=>{
				return {
					name:a.title,
					parame:a.userOption,
					type:a.type					
				}
			})
			const memberInformationTcm = {constitution:JSON.stringify(_this.criterionArr),appFourDiagnosticEntities:appFourDiagnosticEntities,healthId:JSON.parse(localStorage.userInfo).id,userId:_this.userId,userName:_this.userName,id:_this.editId ? Number(_this.editId) : null}
			localStorage.setItem('memberInformationTcm',JSON.stringify(memberInformationTcm))
			
			if(_this.mark == 2  || !_this.editId) {
				uni.navigateTo({
					url: '/pages/quickly/tcm/questionnaireDetailTCM2?userId='+_this.userId+'&sex='+sex+'&isAmended='+_this.isAmended+'&between='+1
				})
			} else if(_this.type == 2) {
				uni.navigateTo({
					url: '/pages/quickly/tcm/questionnaireDetailTCM2?userId='+_this.userId+'&sex='+sex+'&isAmended='+_this.isAmended+'&between='+1
				})
			}
		}
	},
	
}